<?php

/**
 * Created by PhpStorm.
 * User: holy
 * Date: 05/12/2016
 * Time: 15:49
 * 纯数字的验证码;
 */

namespace common\components\captcha;

use yii\captcha\CaptchaAction;

class NumberCaptchaAction extends CaptchaAction {

    public $minLength = 1000;
    public $maxLength = 9999;
    public $fontFile = '@common/components/captcha/FreeSerif.ttf';
//    public $backColor = "#fff";
    public $foreColor = "#848484";

    /**
     * @inheritdoc
     */
    protected function generateVerifyCode() {
        return mt_rand((int) $this->minLength, (int) $this->maxLength);
    }

    /**
     * @inheritdoc
     */
    protected function renderImage($code) {
        return parent::renderImage($this->getText($code));
    }
    /**
     * 
     * @param type $regenerate
     * @return type
     */
    public function getVerifyCode($regenerate = false) {
        return parent::getVerifyCode($regenerate);
    }

    /**
     * @param $code
     * @return string 显示验证码;
     */
    protected function getText($code) {
        return "$code";
    }

}
